package com.company.cloud.goodsrestservice.service.impl;

import com.company.cloud.goodsrestservice.core.AbstractService;
import com.company.cloud.goodsrestservice.dao.ColorMapper;
import com.company.cloud.goodsrestservice.model.Color;
import com.company.cloud.goodsrestservice.service.ColorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


/**
 * Created by reabout on 2018/03/24.
 */
@Service
@Transactional
public class ColorServiceImpl extends AbstractService<Color> implements ColorService {
    @Resource
    private ColorMapper goodsColorMapper;

    private final Logger log = LoggerFactory.getLogger(Color.class);

    public Color chkInsert(String colorName) {
        Color color = findBy("colorName", colorName);
        if (color == null & colorName != "") {
            log.info("New color {}", colorName);
            color = new Color();
            color.setColorName(colorName);
            color.setStatus(2);
            color = findBy("colorName", colorName);
        }
        return color;
    }
}
